package com.tfswx.jcyw.ruleenginedesigner.api;

import com.tfswx.jcyw.ruleenginedesigner.bean.ApiResult;
import com.tfswx.jcyw.ruleenginedesigner.dto.mxstgxgl.*;
import com.tfswx.jcyw.ruleenginedesigner.service.MxstgxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ricky
 * @date 2021/7/2
 */
@RestController
@RequestMapping("/mxstgxgl")
@Api(tags = "模型实体关系管理")
public class MxstgxglController {

    @Resource
    private MxstgxService mxstgxService;

    @ApiOperation("根据项目编码获取实体关系列表")
    @PostMapping("/queryMxstgxListByXmbm")
    public ApiResult<List<MxstgxListByXmbmQueryOutputDTO>> queryMxstgxListByXmbm(@RequestBody @Validated MxstgxListByXmbmQueryInputDTO mxstgxListByXmbmQueryInputDTO) {
        List<MxstgxListByXmbmQueryOutputDTO> mxstgxList = mxstgxService.queryMxstgxListByXmbm(mxstgxListByXmbmQueryInputDTO);
        return ApiResult.success(mxstgxList);
    }

    @ApiOperation("添加模型实体关系")
    @PostMapping("/addMxstgx")
    public ApiResult<String> addMxstgx(@RequestBody @Validated MxstgxAddInputDTO mxstgxAddInputDTO) {
        String mxstgxbm = mxstgxService.addMxstgx(mxstgxAddInputDTO);
        return ApiResult.success(mxstgxbm);
    }

    @ApiOperation("删除模型实体关系")
    @PostMapping("/deleteMxstgx")
    public ApiResult<Boolean> deleteMxstgx(@RequestBody @Validated MxstgxDeleteInputDTO mxstgxDeleteInputDTO) {
        boolean isSucc = mxstgxService.deleteMxstgx(mxstgxDeleteInputDTO);
        return ApiResult.success(isSucc);
    }

    @ApiOperation("修改模型实体关系")
    @PostMapping("/updateMxstgx")
    public ApiResult<Boolean> updateMxstgx(@RequestBody @Validated MxstgxUpdateInputDTO mxstgxUpdateInputDTO) {
        boolean isSucc = mxstgxService.updateMxstgx(mxstgxUpdateInputDTO);
        return ApiResult.success(isSucc);
    }
}
